package com.zm.tools.util.multidatasource;

/**
 * @author zoum
 * @create 2018/6/15 15:17
 */
public class DynamicDataSourceHolder {

    public static final String MASTER = "master";

    public static final String SLAVE = "slave";

    private static final ThreadLocal<String> DATASOURCE_KEY = ThreadLocal.withInitial(() -> "");

    public static void putDatasourceKey(String key){
        DATASOURCE_KEY.set(key);
    }

    public static String getDatasourceKey(){
        return DATASOURCE_KEY.get();
    }

    public static void markMaster(){
        putDatasourceKey(MASTER);
    }

    public static void markSlave(){
        putDatasourceKey(SLAVE);
    }
}
